var fs = require('fs');
var Web3 = require('web3');
var web3 = new Web3('ws://127.0.0.1:8545');

// 获取json文件中的 abi  bytecode
var teamjson;
let abi;
let bytecode;
fs.readFile('../build/contracts/MetaCoin.json', 'utf-8', function(err, data){
    if(err) throw err;
    teamjson = JSON.parse(data);
    abi = teamjson.abi;
    bytecode = teamjson.bytecode;

    let contract_addr = "0x6fc7bB4c1C52fc7Eb42A0D7a57784f815a15Cb6c";
    let from_account = "0xe50E661a54d8555Ca5bC669a1E9D0693E5D775e2";
    let to_account = "0x18F95dc0C80B9d18c67AF993E42e45Ea34B9088e";

    var myContract = new web3.eth.Contract(abi, contract_addr);

    myContract.methods.getBalance(from_account).call().then(console.log);

    // myContract.methods.sendCoin(to_account, 10).send({from: from_account}).then(console.log);      

});




